<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
	<head>
		<title>工序汇报</title>
		<t:base type="jquery,easyui,tools,DatePicker,utils,yongxin_js,yongxin_css,mobile_css"></t:base>
	</head>

	<script>
		
		$(document).ready(function(){
		
	    var char2 = '${processReportPage.fbcph}'.charAt(0);
	    
	    if(char2 == 'S'){
	     $("#fworkshop").val('1002');
	    }
	    
     });
    
    
 	$(function(){
 	
 			$.ajax({
				type : "POST",
				url : "processReportController.do?getProcess&fbcph=${processReportPage.fbcph}",
				data: {pid:$('#fworkshop').val()},
				success : function(jsondata) {
						data = $.parseJSON(jsondata);
						var str ="";
						$(data.obj).each(function(i,j){
							//console.log(j);
							
							str +="<span class='progress'>"+j.typename+"("+j.fbcph+")</span>";
							if(i%6==0){
								str +="<br><br>";
							}
							str +="<span >-----></span>";
							
						});
						//str +=data.msg;
						
						console.log(str);
						$('#div_process').html(str);
						$('#div_nprocess').html(data.msg);
						$('#t_div_nprocess').html(data.msg);
						$('#nprocess').val('${processReportPage.nprocess}');
			
					}
			});
			
				var char=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
			var num = 0;
			var lastCommunAddTr = $("#record_tr");

		   $("#add_btn").click(function() {                                       //增加分卷
		   
		   		document.getElementById('ftrzl').readOnly = false;
		   		
		   		if($(".trRecord").length==1){
		   			if("${processReportPage.fbcph}".indexOf('-')>0){
		   				$("#record_tr").find("#fbcph").get(0).value +=char[num];
		   			}
		   			else{
		   				$("#record_tr").find("#fbcph").get(0).value +="-"+char[num];
		   			}
		   			num++;
		   		}
		   		
		   		
               var tr = $("#temp_tr").clone(true);
               tr.attr('id',tr.attr('id')+char[num]);
          		
          		tr.attr('class','trRecord');
           		
           		if("${processReportPage.fbcph}".indexOf('-')>0){
	   				tr.find("#fbcph").get(0).value +=char[num];
	   			}
	   			else{
	   				tr.find("#fbcph").get(0).value +="-"+char[num];
	   			}
           		
           		
               tr.insertAfter(lastCommunAddTr);
               lastCommunAddTr = tr;
               num++;
              
            });
            
            $("#del_btn").click(function() {                             //删除分卷
              var delIndexs = new Array(0);
              $(".trRecord:gt(0)").each(function(i) {
              		
					if($(this).find("#ck").get(0).checked == true){
                  		delIndexs.splice(delIndexs.length,0,i);
                     	$(this).remove();
                    }
                });
                
                 $(".trRecord").each(function(i) {
                	
                	if($(".trRecord").length==1){
                		
                		document.getElementById('ftrzl').readOnly = true;
                		$('#ftrzl').val('${processReportPage.ftrzl}');
			   			$("#record_tr").find("#fbcph").get(0).value ="${processReportPage.fbcph}";
			   			num=0;
			   			
			   		}
			   		else{
			   			if("${processReportPage.fbcph}".indexOf('-')>0){
			   				$(this).find("#fbcph").get(0).value ="${processReportPage.fbcph}"+char[i];
			   			}
			   			else{
			   				$(this).find("#fbcph").get(0).value ="${processReportPage.fbcph}-"+char[i];
			   			}
			   		}
                 	lastCommunAddTr = $(this);
                 
                });
                
              
            });
            
            $("#save_btn").click(function() {     //保存
               top.$(".ui_state_highlight").hide();
             
             
            //保存之前判断分卷重量是否合理
	         if(!checkFJ()){
	          return false;
	         }
	         
	         /*保存之前判断产出重量是否大于投入重量*/
             if(!checkCC()){
	          return false;
	         }
      
			ajaxdoForm('processReportController.do?save&fstate=1', 'formobj');
			$("#save_btn").hide();
        	$("#add_btn").hide();
            $("#del_btn").hide();
		});
        
        
        
		var step_num = 2;
		var step_lastCommunAddTr = $(".trStep:last");

		$("#addstep_btn").click(function() {//复制一行
			var tr = $("#temp_tr_step").clone();
			tr.attr('id', tr.attr('id') + step_num);
			//	tr.id=tr.attr('id')+num;
			tr.attr('class', 'trStep');
			//   alert(tr.id);
			tr.insertAfter(step_lastCommunAddTr);
			step_lastCommunAddTr = tr;

			tr.find("#step").get(0).innerText = step_num;

			step_num++;
		});

		$("#delstep_btn").click(function() {//复制一行
			var delIndexs = new Array(0);
			$(".trStep:gt(0)").each(function(i) {

				if ($(this).find("#ck").get(0).checked == true) {
					delIndexs.splice(delIndexs.length, 0, i);
					$(this).remove();

				}

			});

			$(".trStep").each(function(i) {

				step_lastCommunAddTr = $(this);
				step_num = ++i;
				$(this).find("#step").get(0).innerText = step_num++;
			});
		});

		selChange();

	});

	function selChange() {

		var sel = $("#fworkshop").val();
		
				$.ajax({
					type : "POST",
					url : "processReportController.do?getMatchinegroupList&process=${processReportPage.cprocess}",
					data : {
						pid : $('#fworkshop').val()
					},
					success : function(jsondata) {
						data = $.parseJSON(jsondata);
						console.log(data);
						$('#fmatchinegroup').html(data.msg);
						$('#fmatchinegroup').val(
								"${processReportPage.fmatchinegroup}");
					}
				});

	}
</script>


	<body scroll="no">
		<div id="wrapper">
					<t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" tiptype="1"
						action="processReportController.do?save&fstate=2" beforeSubmit="checkNprocessEmpty">
						<input id="id" name="id" type="hidden" value="${processReportPage.id }">
						<input type="hidden" id="cprocess" name="cprocess" class="mytxt" ignore="ignore" value="${processReportPage.cprocess}">
						<input type="hidden" id="trzl" name="trzl" value="${processReportPage.ftrzl}">
						<input type="hidden" id="process" name="process" class="mytxt" ignore="ignore" value="p2_1">

						<table  cellpadding="0" cellspacing="1" class="formtable">
							<tr>
								<td align="center" colspan=11>
									<label class="Validform_label">
										粗轧工序汇报单
									</label>
								</td>
							</tr>
							<tr>
								<td align="center" colspan=11 style="background-color: white; padding: 20px">
									<div id="div_process"></div>
								</td>
							</tr>
							<tr style="display: none">
								<td align="center">
									<label class="Validform_label">
										制单时间
									</label>
								</td>
								<td class="value" colspan=10>
									<input class="mytxt" id="updateDate" name="updateDate" ignore="ignore" style="width: 140px;"
										value="<fmt:formatDate value='${processReportPage.updateDate}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/>" ReadOnly>
									<!--
						<input class="Wdate"  onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width: 150px" id="createDate" name="createDate"  class="mytxt"  ignore="ignore" >
					    -->
								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										生产车间
									</label>
								</td>
								<td class="value" colspan=10>
								    <!--   <t:dictSelect field="fworkshop" typeGroupCode="workshop" hasLabel="false"  defaultVal="${processReportPage.fworkshop}" extendJson="{id:sel2}"></t:dictSelect> -->
								     <select  id="fworkshop"  name="fworkshop" onchange="selChange()">
								     <c:forEach items="${workshopList}" var="workshop">
								        <option value="${workshop.id}"   <c:if test="${workshop.id==processReportPage.fworkshop}"> selected="selected"</c:if>>${workshop.name}</option>
								     </c:forEach>
								     </select>	   
								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										班组
									</label>
								</td>
								<td class="value" colspan=10>
								     <t:dictSelect field="fworkgroup" typeGroupCode="team" hasLabel="false"  defaultVal="${processReportPage.fworkgroup}" extendJson="{id:sel2}"></t:dictSelect>
								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										机组
									</label>
								</td>
								<td class="value" colspan=10>
								  <select id='fmatchinegroup' name='fmatchinegroup'><option value=''>请选择</option></select>
								<!--
								
								     <select  id="fworkshop"  name="fworkshop" onchange="tt()">
								     <c:forEach items="${matchinegroupList}" var="matchinegroup">
								        <option value="${matchinegroup.name}"   <c:if test="${matchinegroup.name==processReportPage.fmatchinegroup}"> selected="selected"</c:if>>${matchinegroup.name}</option>
								     </c:forEach>
								     </select>	  
								
								  --><!--	<input id="fmatchinegroup" name="fmatchinegroup" style="width: 140px;" class="mytxt" ignore="ignore"
										value="${processReportPage.fmatchinegroup}">  -->
								</td>
							</tr>
							<tr>
							   <td align="center">
							   <label class="Validform_label">
										开工时间
							   </label>
							   </td>
							   	<td class="value" colspan=10>
									<input class="mytxt" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" id="startDate" name="startDate" ignore="ignore" style="width: 140px;"
										value="<fmt:formatDate value='${processReportPage.startDate}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/>" >
								</td>
							</tr>
							<tr style="display: none">
								<td align="center">
									<label class="Validform_label">
										制单人
									</label>
								</td>
								<td class="value" colspan=11>
									<input id="createBy" name="createBy" style="width: 140px;" class="mytxt" ignore="ignore" readOnly
										value="${processReportPage.createBy}">
								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										本厂批号
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入厚度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入宽度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入重量
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										产出厚度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										产出宽度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										产出重量
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										报废重量
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										成材率
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										质量情况
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										下一工序
									</label>
								</td>
							</tr>
							<tr id="record_tr" class="trRecord">
								<td align="center" class="value">
								    <input type="checkbox" id="ck"  style="position: relative; top: -999em;"  >
									<input id="fbcph" name="fbcph" style="width: 120px;" class="mytxt" ignore="ignore" value="${processReportPage.fbcph}"
										ReadOnly>
										<input type="hidden"  name="fwlname" value="${processReportPage.fwlname}">
								</td>
								<td align="center" class="value">
									<input id="ftrhd" name="ftrhd" class="mytxt" ignore="ignore" value="${processReportPage.ftrhd}">
								</td>
								<td align="center" class="value">
									<input id="ftrkd" name="ftrkd" class="mytxt" ignore="ignore" value="${processReportPage.ftrkd}">
								</td>
								<td align="center" class="value">
									<input id="ftrzl" name="ftrzl" class="mytxt" ignore="ignore" ReadOnly  value="${processReportPage.ftrzl}">
								</td>
								<td align="center" class="value">
									<input id="fcchd" name="fcchd" dataType="d" class="mytxt" ignore="ignore" value="${processReportPage.fcchd}" >
								</td>
								<td align="center" class="value">
									<input id="fcckd" name="fcckd" dataType="d" class="mytxt" ignore="ignore" value="${processReportPage.fcckd}">
								</td>

								<td align="center" class="value">
									<input id="fcczl" name="fcczl" dataType="d" class="mytxt" ignore="ignore" value="${processReportPage.fcczl}" onkeyup="getRate()">
								</td>
								<td align="center" class="value">
									<input id="fbfzl" name="fbfzl" class="mytxt" ignore="ignore" value="${processReportPage.fbfzl}" ReadOnly>
								</td>
								<td align="center" class="value">
									<input id="frate" name="frate" class="mytxt" ignore="ignore" value="${processReportPage.frate}" ReadOnly>
								</td>
								<td align="center" class="value">
									<input id="fnote" name="fnote" class="mytxt" ignore="ignore" value="${processReportPage.fnote}">
								</td>
								<td align="center" class="value">
									<div id="div_nprocess" class="div_nprocess"></div>
								</td>
							</tr>

						</table>

						<div id="dlg-buttons" >
							<table cellpadding="0" cellspacing="0" style="width: 100%" >
								<tr>
									<td style="padding-top: 10px">
										<a href="#" class="easyui-linkbutton btn"  iconCls="icon-save" id="save_btn" >保存</a>
										<a href="#" class="easyui-linkbutton btn" iconCls="icon-add" id="add_btn">增加批号</a>
										<a href="#" class="easyui-linkbutton btn" iconCls="icon-remove" id="del_btn">删除批号</a>
									</td>
								</tr>
							</table>
						</div>


						<div style="margin-top: 20px;">
							<table align="left" cellpadding="0" cellspacing="1" class="formtable">
								<tr>
									<td align="center" colspan=11>
										<label class="Validform_label">
											轧制工艺
										</label>
									</td>

								</tr>
								<tr>
									<td align="center" nowrap>
										<label class="Validform_label">
											道次
										</label>
									</td>
									<td align="center">
										<label class="Validform_label">
											开卷厚度
										</label>
									</td>
									<td align="center">
										<label class="Validform_label">
											收卷厚度
										</label>
									</td>
									<td align="center">
										<label class="Validform_label">
											开卷张力
										</label>
									</td>
									<td align="center">
										<label class="Validform_label">
											收卷张力
										</label>
									</td>
									<td align="center">
										<label class="Validform_label">
											轧制力
										</label>
									</td>
									<td align="center">
										<label class="Validform_label">
											速度
										</label>
									</td>
									<td align="center">
										<label class="Validform_label">
											压下量
										</label>
									</td>
									<td align="center">
										<label class="Validform_label">
											轧辊信息
										</label>
									</td>

									<td align="center">
										<label class="Validform_label">
											辊面
										</label>
									</td>
									<td align="center">
										<label class="Validform_label">
											备注
										</label>
									</td>
								</tr>

								<c:if test="${fn:length(rollingList)  > 0 }">
									<c:forEach items="${rollingList}" var="stepPage" varStatus="stuts">
										<tr id="step_tr" class="trStep">
											<td align="center" class="value" style="text-align: right">
												<input id="r_id" name="r_id" type="hidden" value="${stepPage.id }">
												<input type="checkbox" id="ck">
												<span id="step">${stuts.index+1}</span>
											</td>
											<td align="center" class="value">
												<input id="fkjhd" name="fkjhd" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fkjhd}">

											</td>
											<td align="center" class="value">
												<input id="fsjhd" name="fsjhd" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fsjhd}">

											</td>
											<td align="center" class="value">
												<input id="fkjzl" name="fkjzl" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fkjzl}">

											</td>
											<td align="center" class="value">
												<input id="fsjzl" name="fsjzl" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fsjzl}">

											</td>
											<td align="center" class="value">
												<input id="fzzl" name="fzzl" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fzzl}">

											</td>
											<td align="center" class="value">
												<input id="fsd" name="fsd" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fsd}">
											</td>
											<td align="center" class="value">
												<input id="fyxl" name="fyxl" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fyxl}">
											</td>

											<td align="center" class="value">
												<t:dictSelect field="fzhxx" typeGroupCode="zhxx" hasLabel="false" defaultVal="${stepPage.fzhxx}"
													extendJson="{id:sel}"></t:dictSelect>
											</td>

											<td align="center" class="value">
												<t:dictSelect field="fhm" typeGroupCode="hm" hasLabel="false" defaultVal="${stepPage.fhm}" extendJson="{id:sel}"></t:dictSelect>
											</td>

											<td align="center" class="value">
												<input id="note" name="note" style="width: 140px;" class="mytxt" ignore="ignore" value="${stepPage.fnote}">
											</td>
										</tr>
									</c:forEach>
								</c:if>

								<c:if test="${fn:length(rollingList)  <= 0 }">
									<tr id="step_tr" class="trStep">
										<td class="value" style="text-align: right">
											<input id="id" name="r_id" type="hidden" value="${stepPage.id }">
											<span id="step">1</span>

										</td>
										<td align="center" class="value">
											<input id="fkjhd" name="fkjhd" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fkjhd}">
										</td>
										<td align="center" class="value">
											<input id="fsjhd" name="fsjhd" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fsjhd}">

										</td>
										<td align="center" class="value">
											<input id="fkjzl" name="fkjzl" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fkjzl}">

										</td>
										<td align="center" class="value">
											<input id="fsjzl" name="fsjzl" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fsjzl}">

										</td>
										<td align="center" class="value">
											<input id="fzzl" name="fzzl" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fzzl}">

										</td>
										<td align="center" class="value">
											<input id="fsd" name="fsd" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fsd}">

										</td>
										<td align="center" class="value">
											<input id="fyxl" name="fyxl" class="mytxt" ignore="ignore" dataType="d" value="${stepPage.fyxl}">
										</td>

										<td align="center" class="value">
											<t:dictSelect field="fzhxx" typeGroupCode="zhxx" hasLabel="false" defaultVal="${stepPage.fzhxx}"
												extendJson="{id:sel}"></t:dictSelect>
										</td>

										<td align="center" class="value">
											<t:dictSelect field="fhm" typeGroupCode="hm" hasLabel="false" defaultVal="${stepPage.fhm}" extendJson="{id:sel}"></t:dictSelect>
										</td>

										<td align="center" class="value">
											<input id="note" name="note" style="width: 140px;" class="mytxt" ignore="ignore" value="${stepPage.fnote}">
										</td>
									</tr>

								</c:if>
							</table>


						</div>
					</t:formvalid>

					<div id="dlg-buttons">
						<table cellpadding="0" cellspacing="0"  align="left" style="width: 100%">
							<tr>
								<td style="padding-top: 10px" >
									<a href="#" class="easyui-linkbutton btn" iconCls="icon-add" id="addstep_btn">增加道次</a>
									<a href="#" class="easyui-linkbutton btn" iconCls="icon-remove" id="delstep_btn">删除道次</a>
								</td>
							</tr>
						</table>
					</div>
					
                        


					<table style="width: 600px; display: none" cellpadding="0" cellspacing="1">

						<tr id="temp_tr">
							<td align="center" class="value" nowrap>
								<input type="checkbox" id="ck">
								<input id="fbcph" name="fbcph" class="mytxt" ignore="ignore" style="width: 120px" value="${processReportPage.fbcph}"
									ReadOnly>

							</td>
							<td align="center" class="value">
								<input id="ftrhd" name="ftrhd" class="mytxt" ignore="ignore" value="${processReportPage.ftrhd}">

							</td>
							<td align="center" class="value">
								<input id="ftrkd" name="ftrkd" class="mytxt" ignore="ignore" value="${processReportPage.ftrkd}">

							</td>

							<td align="center" class="value">
								<input id="ftrzl" name="ftrzl" class="mytxt" ignore="ignore">

							</td>
							<td align="center" class="value">
								<input id="fcchd" name="fcchd" dataType="d" class="mytxt" ignore="ignore" >

							</td>
							<td align="center" class="value">
								<input id="fcckd" name="fcckd" d ataType="d" class="mytxt" ignore="ignore">

							</td>

							<td align="center" class="value">
								<input id="fcczl" name="fcczl" dataType="d" class="mytxt" ignore="ignore" onkeyup="getRate()">

							</td>
							<td align="center" class="value">
								<input id="fbfzl" name="fbfzl" class="mytxt" ignore="ignore" ReadOnly>

							</td>
							<td align="center" class="value">
								<input id="frate" name="frate" class="mytxt" ignore="ignore" ReadOnly>

							</td>
							<td align="center" class="value">
								<input id="fnote" name="fnote" class="mytxt" ignore="ignore">

							</td>
							<td align="center" class="value">
								<div id="t_div_nprocess" class="div_nprocess"></div>
							</td>
						</tr>

						<tr id="temp_tr_step">
							<td align="center" class="value" nowrap>
								<input id="id" name="r_id" type="hidden" value="${stepPage.id}">
								<input type="checkbox" id="ck">
								<span id="step"></span>
							</td>
							<td align="center" class="value">
								<input id="fkjhd" name="fkjhd" class="mytxt" ignore="ignore" value="${stepPage.fkjhd}">

							</td>
							<td align="center" class="value">
								<input id="fsjhd" name="fsjhd" class="mytxt" ignore="ignore" value="${stepPage.fsjhd}">

							</td>
							<td align="center" class="value">
								<input id="fkjzl" name="fkjzl" class="mytxt" ignore="ignore" value="${stepPage.fkjzl}">

							</td>
							<td align="center" class="value">
								<input id="fsjzl" name="fsjzl" class="mytxt" ignore="ignore" value="${stepPage.fsjzl}">

							</td>
							<td align="center" class="value">
								<input id="fzzl" name="fzzl" class="mytxt" ignore="ignore" value="${stepPage.fzzl}">

							</td>
							<td align="center" class="value">
								<input id="fsd" name="fsd" class="mytxt" ignore="ignore" value="${stepPage.fsd}">

							</td>
							<td align="center" class="value">
								<input id="fyxl" name="fyxl" class="mytxt" ignore="ignore" value="${stepPage.fyxl}">

							</td>

							<td align="center" class="value">
								<t:dictSelect field="fzhxx" typeGroupCode="zhxx" hasLabel="false" defaultVal="${stepPage.fzhxx}"
									extendJson="{id:sel}"></t:dictSelect>
							</td>

							<td align="center" class="value">
								<t:dictSelect field="fhm" typeGroupCode="hm" hasLabel="false" defaultVal="${stepPage.fhm}" extendJson="{id:sel}"></t:dictSelect>
							</td>

							<td align="center" class="value">
								<input id="note" name="note" style="width: 140px;" class="mytxt" ignore="ignore" value="${stepPage.fnote}">
							</td>
						</tr>

					</table>
			</div>
	</body>